#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int t;
string s;
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cin >> t;
    while (t--) {
        cin >> s;
        int n = s.size();
        bool carry  = false;

        for (int i = 0; i < n - 1; i++) {
            int x = s[i]- '0', y = s[i+1] - '0';
            if (x+y >= 10) carry = true;
        }

        if (!carry) {
            int x = s[0]- '0', y = s[1] - '0';
            cout << x+y ;

            cout << s.substr(2) << endl;
        } else {
            int idx = -1, num = -1;
            for (int i = n-1; i >= 1; i--) {
                int x = s[i]- '0', y = s[i-1] - '0';
                if (x+y >= 10) {
                    idx = i;
                    break;
                }
            }

            cout << s.substr(0, idx-1);
            cout << (s[idx]-'0') + (s[idx-1]-'0');
            cout << s.substr(idx+1) << endl;
        }
    }


    return 0;
}